<?php
ob_start();
include("connection/connection.php");
$typeScheme=$_POST['typeScheme'];
$frm=$_POST['frmId'];
if(isset($_POST['add_new']))
{
	$loc_id=$_POST['loc_id'];
	
	$source=$_POST['source'];
	$Location=$_POST['Location'];
	$Longitude=$_POST['Longitude'];
	$Latitude=$_POST['Latitude'];
	$source_status=$_POST['source_status'];
	$yeildMin=$_POST['yeildMin'];
	$yeildMax=$_POST['yeildMax'];
	$waterMin=$_POST['waterMin'];
	$waterMax=$_POST['waterMax'];
	
	$pH=$_POST['pH'];
	$TDS=$_POST['TDS'];
	$cl=$_POST['cl'];
	$F=$_POST['F'];
	$no3=$_POST['no3'];
	$testing_date=$_POST['testing_date'];
	
	$qr="insert into tbl_dtls_q1_sws(id,loc_id,source,location,longitude,latitude,yield_min,yield_max,water_table_min,water_table_max,pH,TDS,Cl,F,no3,testing_date,current_status) values('','$loc_id','$source','$Location','$Longitude','$Latitude','$yeildMin','$yeildMax','$waterMin','$waterMax','$pH','$TDS','$cl','$F','$no3','$testing_date','$source_status')";
	$res=mysql_query($qr);
	//print_r($res);
	////////////////////////code for maintaining user history///////////////////
	if($typeScheme=="P&T" || $typeScheme=="TSS(P&T)")
	{
		$qryHistory="insert into tbl_new_user_history(user_id,form_id,action_id,ip_address,modify_date,user_type,user_name) values('$_POST[loginId]','$frm','4','$_SERVER[REMOTE_ADDR]',NOW(),'$_POST[userType]','$_POST[name]')";
	}
	if($typeScheme=="Piped")
	{
		$qryHistory="insert into tbl_new_user_history(user_id,form_id,action_id,ip_address,modify_date,user_type,user_name) values('$_POST[loginId]','$frm','30','$_SERVER[REMOTE_ADDR]',NOW(),'$_POST[userType]','$_POST[name]')";
	}
	if($typeScheme=="Sanitary Diggs")
	{
		$qryHistory="insert into tbl_new_user_history(user_id,form_id,action_id,ip_address,modify_date,user_type,user_name) values('$_POST[loginId]','$frm','56','$_SERVER[REMOTE_ADDR]',NOW(),'$_POST[userType]','$_POST[name]')";
	}
	
	
	mysql_query($qryHistory);
	///////////////////////////////
	
	
	$update_query="update tbl_dtls_q1_main set no_sources=(no_sources+1) where id='$loc_id'";
	$res1=mysql_query($update_query);
	if($res)
	{
		header("location:q1.php");
	}
}		
?>